﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Hook.Common
{
    public static class Expansion
    {
        /// <summary>
        /// byte数组中取int数值，本方法适用于(低位在前，高位在后)的顺序，和和intToBytes（）配套使用
        /// </summary>
        /// <param name="src">byte数组</param>
        /// <param name="offset">从数组的第offset位开始</param>
        /// <returns></returns>
        public static int bytesToInt(this byte[] ary, int offset)
        {
            int value;
            value = (int)((ary[offset] & 0xFF)
                    | ((ary[offset + 1] << 8) & 0xFF00)
                    | ((ary[offset + 2] << 16) & 0xFF0000)
                    | ((ary[offset + 3] << 24) & 0xFF000000));
            return value;
        }

    }
}
